home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Palettes
/
ScrollViewDeluxe
/
SVDInspector.m
< prev
Wrap
Text File
|
1993-11-01
|
5KB
|
169 lines
#import "SVDInspector.h"
#import "ScrollViewDeluxe.h"
typedef struct { @defs (ScrollView) } *scrollViewId;
typedef struct { @defs (Scroller) } *scrollerId;
#define NONE 0
#define LINE 1
#define BEZEL 2
#define RIDGE 3
#define VERTIC 0
#define HORIZ 1
#define BLACK 0
#define DKGRAY 1
#define LTGRAY 2
#define WHITE 3
@implementation SVDInspector
- init
{
char path[MAXPATHLEN];
NXBundle *bundle = [NXBundle bundleForClass:[self class]];
[super init];
[bundle getPath:path forResource:"SVDInspector"
ofType:"nib"];
[NXApp loadNibFile:path owner:self withNames:NO];
return self;
}
- (BOOL)wantsButtons { return NO; }
- revert:sender
{
int i=0;
id scroller;
float gray;
scroller = [object vertScroller];
if (!scroller) scroller = [object horizScroller];
switch ([object borderType]) {
case NX_NONE:
i = NONE;
break;
case NX_LINE:
i = LINE;
break;
case NX_BEZEL:
i = BEZEL;
break;
case NX_RIDGE:
i = RIDGE;
break;
}
[borderMatrix selectCellWithTag:i];
gray = [object backgroundGray];
i = ((gray == NX_BLACK)? 0 : ((gray < 0.5) ? 1 : ((gray < 0.8) ? 2 : 3)));
[backGrayMatrix selectCellWithTag:i];
if (((scrollViewId) object)->_sFlags.vScrollerRequired)
[[scrollerMatrix findCellWithTag:VERTIC] setIntValue:1];
else [[scrollerMatrix findCellWithTag:VERTIC] setIntValue:0];
if (((scrollViewId) object)->_sFlags.hScrollerRequired)
[[scrollerMatrix findCellWithTag:HORIZ] setIntValue:1];
else [[scrollerMatrix findCellWithTag:HORIZ] setIntValue:0];
[lineCell setFloatValue:((scrollViewId) object)->lineAmount];
[pageCell setFloatValue:((scrollViewId) object)->pageContext];
[pageUpDownSwitch setState:[object pageUpDownButtonsVisible]];
[pageLeftRightSwitch setState:[object pageLeftRightButtonsVisible]];
[zoomSwitch setState:[object zoomButtonVisible]];
[topRulerSwitch setState:[object topViewVisible]];
[leftRulerSwitch setState:[object leftViewVisible]];
[deluxeMatrix display];
return [super revert:sender];
}
- ok:sender
{
int i=0;
float gray= 0.0;
switch ([borderMatrix selectedTag]) {
case NONE:
i = NX_NONE;
break;
case LINE:
i = NX_LINE;
break;
case BEZEL:
i = NX_BEZEL;
break;
case RIDGE:
i = NX_RIDGE;
break;
}
[object setBorderType:i];
switch ([backGrayMatrix selectedTag]) {
case 0:
gray = NX_BLACK;
break;
case 1:
gray = NX_DKGRAY;
break;
case 2:
gray = NX_LTGRAY;
break;
case 3:
gray = NX_WHITE;
break;
}
[object setBackgroundGray:gray];
[object setVertScrollerRequired:
[[scrollerMatrix findCellWithTag:VERTIC] intValue]];
[object setHorizScrollerRequired:
[[scrollerMatrix findCellWithTag:HORIZ] intValue]];
if ([lineCell floatValue] < 1.0) [lineCell setFloatValue:1.0];
[lineCell setFloatValue:ceil([lineCell floatValue])];
((scrollViewId) object)->lineAmount = [lineCell floatValue];
if ([pageCell floatValue] < 1.0) [pageCell setFloatValue:1.0];
[pageCell setFloatValue:ceil([pageCell floatValue])];
((scrollViewId) object)->pageContext = [pageCell floatValue];
[object setPageLeftRightButtonsVisible:[pageLeftRightSwitch state]];
[object setPageUpDownButtonsVisible:[pageUpDownSwitch state]];
[object setZoomButtonVisible:[zoomSwitch state]];
[object setTopViewVisible:[topRulerSwitch state]];
[object setLeftViewVisible:[leftRulerSwitch state]];
return [super ok:sender];
}
@end
@interface Menu(attachedMenu)
@end
@implementation Menu(attachedMenu)
- attachedMenu { return attachedMenu; }
@end
@implementation ScrollView(Replace)
extern id (*_zoneAlloc)(Class aClass, unsigned int indIvarBytes, NXZone *zone);
static id (*oldAlloc)(Class aClass, unsigned int indIvarBytes, NXZone *zone);
id SVDAlloc(Class aClass, unsigned int indIvarBytes, NXZone *zone)
{
if(aClass == [ScrollView class]) {
id menuMatrix =[[[[NXApp mainMenu] attachedMenu] attachedMenu]
itemList];
id menuCell = [menuMatrix selectedCell];
// If menu cell exists, is enabled & has the correct title, use Deluxe
if(([NXApp currentEvent]->flags&NX_COMMANDMASK) && menuCell &&
[menuCell isEnabled] && ([menuMatrix selectedRow] == 5))
return oldAlloc([ScrollViewDeluxe class], indIvarBytes, zone);
}
return oldAlloc(aClass, indIvarBytes, zone);
}
+ finishLoading:(struct mach_header *)header
{
oldAlloc = _zoneAlloc;
_zoneAlloc = SVDAlloc;
return self;
}
@end